﻿using System.ComponentModel.Composition;
using Caliburn.Micro;
using OPSYS_Schematic.UIInfrastructure;

namespace OPSYS_Schematic.Presentation.Parts
{
    [MenuPart(BaseMenu = WorkbenchName.LanguagePart, PreviousMenu = WorkbenchName.EnglishPart)]
    [Export(typeof (ILanguagePart))]
    public class ChinesePart : MenuPart, ILanguagePart
    {
        public ChinesePart()
            : base(WorkbenchName.ChinesePart)
        {
            IsCheckable = true;
        }

        public override void Execute()
        {
            IoC.Get<IResourceService>().ChangeLanguage("zh-cn");
            IoC.Get<IConfigurationService>()[this].SaveProperty<MenuPart>(this, i => i.IsChecked);
        }

        public override void OnAttached()
        {
            IoC.Get<IConfigurationService>()[this].LoadProperty<MenuPart>(this, i => i.IsChecked);
        }
    }
}